import Vuex from 'vuex'
import Vue from 'vue';
import createPersistedState from "vuex-persistedstate"
Vue.use(Vuex)

const store = new Vuex.Store({
	plugins: [createPersistedState({
		key:"mrk_app_config",
		storage: {
			 getItem:(key)=>uni.getStorageSync(key),
			 setItem: (key,value)=>uni.setStorageSync(key,value),
			 removeItem:(key)=>uni.removeStorageSync(key)
		}
	})],
	state: {
		userInfo: {},
		token:null,
		failureTime:null,
		local:{
			lat:"",
			longitude:""
		}
	},
	mutations: {
		SET_TOKEN(state,token){
			
			state.token=token;
		},
		SET_USERINFO(state,userInfo){
			state.userInfo=userInfo;
		},
		SET_LOCAL(state,local){
			state.local=local;
		},
		SET_FAILURETIME(state,failureTime){
			state.failureTime = failureTime
		}
	},
	actions:{},
	getters:{}
});
export default store;
